﻿using System;
using Autodesk.Revit.DB;

namespace SectionSignAndFilled.StairsRoomPlanSign.ModelLayer
{
	public class ViewData
	{
		public double CutHeightZ
		{
			get
			{
				return this.dCutHeightZ;
			}
			private set
			{
				this.dCutHeightZ = value;
			}
		}

		public double TopHeightZ
		{
			get
			{
				return this.dTopHeightZ;
			}
			private set
			{
				this.dTopHeightZ = value;
			}
		}

		public double BottomHeightZ
		{
			get
			{
				return this.dBottomHeightZ;
			}
			private set
			{
				this.dBottomHeightZ = value;
			}
		}

		public double ViewDepthZ
		{
			get
			{
				return this.m_dViewDepthZ;
			}
			private set
			{
				this.m_dViewDepthZ = value;
			}
		}

		public ViewPlan ViewPlan
		{
			get
			{
				return this.m_viewPlan;
			}
		}

		public double UnderBottomZ
		{
			get
			{
				return this.m_dUnderBottomDouble;
			}
			private set
			{
				this.m_dUnderBottomDouble = value;
			}
		}

		public double? NowViewLevelZ
		{
			get
			{
				return this.m_dNowViewLevelZ;
			}
			private set
			{
				this.m_dNowViewLevelZ = value;
			}
		}

		public ViewData(ViewPlan viewPlan)
		{
			PlanViewRange viewRange = viewPlan.GetViewRange();
			this.m_doc = viewPlan.Document;
            this.CutHeightZ = this.GetALevelValue(viewRange, (PlanViewPlane)0);
            this.TopHeightZ = this.GetALevelValue(viewRange, (PlanViewPlane)1);
            this.BottomHeightZ = this.GetALevelValue(viewRange, (PlanViewPlane)2);
            this.ViewDepthZ = this.GetALevelValue(viewRange, (PlanViewPlane)3);
            this.UnderBottomZ = this.GetALevelValue(viewRange, (PlanViewPlane)4);
			if (viewPlan.GenLevel != null)
			{
				this.NowViewLevelZ = new double?(viewPlan.GenLevel.Elevation);
			}
			this.m_viewPlan = viewPlan;
		}

		private double GetALevelValue(PlanViewRange viewRange, PlanViewPlane useViewPlanKind)
		{
			double num = double.MaxValue;
			Level level = this.m_doc.GetElement(viewRange.GetLevelId(useViewPlanKind)) as Level;
			if (level != null)
			{
				num = level.Elevation;
				double offset = viewRange.GetOffset(useViewPlanKind);
				num += offset;
			}
			return num;
		}

		private double dCutHeightZ;

		private double dTopHeightZ;

		private double dBottomHeightZ;

		private double m_dViewDepthZ;

		private double m_dUnderBottomDouble;

		private ViewPlan m_viewPlan;

		private Document m_doc;

		private double? m_dNowViewLevelZ = null;
	}
}
